package com.lm.survey.model;

import java.util.ArrayList;
import java.util.List;

import com.lm.survey.logic.Cache;

public class QuestionRelation {
    String pcode;
    int qid;
    String relation;
    List<Integer> allowRels = null;
    String questionName;
    public String getPcode() {
        return pcode;
    }
    public String getQuestionName() {
        return questionName;
    }
    public void setQuestionName(String questionName) {
        this.questionName = questionName;
    }
    public void setPcode(String pcode) {
        this.pcode = pcode;
    }
    public int getQid() {
        return qid;
    }
    public void setQid(int qid) {
        this.qid = qid;
       
    }
    public String getRelation() {
        return relation;
    }
    public void setRelation(String relation) {
        this.relation = relation;
        allowRels = new ArrayList<Integer>();
        if(relation!=null){
            String[] str = relation.split(",");
            for(int i=0;i<str.length;i++){
                allowRels.add(Integer.parseInt(str[i]));
            }
        }
       
    }
    public List<Integer> getAllowRels(){
        return this.allowRels;
    }
    public boolean haveRelation(int i){
        if(this.relation==null){
            return false;
        }
        String rel = i+"";
        return this.relation.indexOf(rel)!=-1;
    }
    
    
}
